<template>
  <div class="dashboard-container body-min-width">
    <h2 class="head-big-title">Tambah Kategori Produk {{newData.categoryName?newData.categoryName:'Produk A'}}</h2>
    <Pathnavigation style="margin-left: 3%;"></Pathnavigation>
    <div style="width: 92%;margin: 0 4% 30px 4%;background-color: white;text-align: left;padding: 10px 1% 50px 2%;">
      <el-form
        :inline="true"
        :model="newData"
        label-position="top"
        size="medium"
        label-width="110px">
        <el-form-item label="Nama Kategori: " class="one-hang">
          <el-input v-model="newData.categoryName" @input="changeNew($event)" placeholder="Nama" maxlength="50"></el-input>
        </el-form-item>
        <el-form-item label="Aturan Susunan: " class="one-hang">
          <el-input v-model="newData.index" @input="changeNew($event)" placeholder="Aturan Susunan" type="number"></el-input>
        </el-form-item>
<!--        <el-form-item label="状态: " class="one-hang">-->
<!--          <el-switch-->
<!--            active-color="#13ce66"-->
<!--            inactive-color="#ff4949"-->
<!--            active-value="1"-->
<!--            inactive-value="0">-->
<!--          </el-switch>-->
<!--        </el-form-item>-->
        <div>
          <el-button type="primary" @click="newDataClick" style="float: right;margin-left: 100px;">Cipta</el-button>
          <el-button @click="$router.push({name: 'Category'})" style="float: right;">Balik</el-button>
        </div>
      </el-form>
    </div>
  </div>
</template>

<script>
import { newCategoryApi } from '@/api/user'

export default {
  name: 'CustomersDetails',
  data() {
    return {
      tableData: [],
      newData: {},
      orderChart: ''
    }
  },
  mounted() {

  },
  methods: {
    newDataClick() {
      localStorage.removeItem('categoryList')
      newCategoryApi(this.newData).then(res => {
        this.$message({
          message: 'success',
          type: 'success'
        })
        this.newData = {}
        this.$router.push({ name: 'Category' })
      }).catch(err => {
        console.log(err)
      })
    }
  }
}
</script>

<style lang="scss" scoped>
  .head-big-title{
    text-align: left;
    font-size: 20px;
    margin: 20px 0 0 3%;
  }
  .dashboard-container{
    margin-top: 20px;
    text-align: center;
  }
  .avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    line-height: 178px;
    text-align: center;
  }
  .avatar {
    width: 178px;
    height: 178px;
    display: block;
  }
</style>
<style scoped>
  /deep/.head-search label{
    line-height: 30px;
  }
  .one-hang{
    display: block;
  }
  .big-title{
    text-align: left;
    font-size: 19px;
    margin: 20px 0;
  }
</style>
